;	Copyright (C) 2009 Salil Bhagurkar
;	
;	This file is part of ViSE
;	
;	ViSE is free software: you can redistribute it and/or modify
;	it under the terms of the GNU Lesser General Public License as published by
;	the Free Software Foundation, either version 3 of the License, or
;	(at your option) any later version.
;	
;	ViSE is distributed in the hope that it will be useful,
;	but WITHOUT ANY WARRANTY; without even the implied warranty of
;	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;	GNU Lesser General Public License for more details.
;	
;	You should have received a copy of the GNU Lesser General Public License
;	along with ViSE.  If not, see <http://www.gnu.org/licenses/>.


;Startup file for the whole kernel

[BITS 32] 
SYS_CODE_SEL equ 0x8
SYS_DATA_SEL equ 0x10
global start
start:
cli
	mov esp,0x90000
	jmp stublet


;This is the multiboot header required by grub loader. it specifies the code,data size

ALIGN 4
mboot:

    MULTIBOOT_PAGE_ALIGN	equ 1<<0
    MULTIBOOT_MEMORY_INFO	equ 1<<1
    MULTIBOOT_AOUT_KLUDGE	equ 1<<16
    MULTIBOOT_HEADER_MAGIC	equ 0x1BADB002
    MULTIBOOT_HEADER_FLAGS	equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
    MULTIBOOT_CHECKSUM	equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
    EXTERN code, bss, end


    dd MULTIBOOT_HEADER_MAGIC
    dd MULTIBOOT_HEADER_FLAGS
    dd MULTIBOOT_CHECKSUM
    
  
    dd mboot
    dd code
    dd bss
    dd end
    dd start

stublet:

    nop
    nop
    nop

extern _init_arch
extern __setgdt
extern __setidt

call __setgdt
call __setidt

call _init_arch

jmp $


global _callbios
_callbios:
pusha
call SYS_CODE_SEL:0x600
popa
ret





section .data

global _arch_kernel_start
_arch_kernel_start dd start
global _arch_kernel_end
_arch_kernel_end dd end
